<?php 
class Application_Model_TaskComplete extends Application_Model_DomainObject {
    
    protected $_id;
    
    protected $_taskId;
    
    protected $_userId; 
    
    protected $_dateCreated;
    
    /**
     * 获得某个任务的完成人数
     * @param type $taskId 任务id
     * @return type 人数
     */
    public static function getCompleteNumByTaskId($taskId)
    {
        return self::getDao()->count(array("taskId = "=>$taskId));
    }
    
    public static function getFileds($completeSearch,$pagesize,$pageindex)
    {
        return self::getDao()->queryPage($completeSearch->getSearchFileds(), " id desc ", $pagesize, $pageindex);
    }
    
    public function getTaskName()
    {
        $taskItem = Application_Model_Task::load($this->_taskId);
        return $taskItem->Name;
    }
    
    public function getUserInfo()
    {
        return Application_Model_User::load($this->_userId);
    }
    
    public static function getByTaskIdUserId($taskId,$userId)
    {
        $completeItem = self::getDao()->count(array("taskId = "=>$taskId," and userId = "=>$userId));
        if($completeItem == 0){
            return false;
        } else {
            return true;
        }
    }
}